<div id="tab5" class="tab">
    <div class="tab-labels">
        <div class="xian"></div>
        本车车损
    </div>
    <div id="div3">
        <form action="">
            <table class="layui-table">
                <tr style="background:#4e73df;color: #fff;" class="ys">
                    <td>车牌号</td>
                    <td>车型型号</td>
                    <td>车架号</td>
                    <td>发动机号</td>
                    <td>驾驶员</td>
                    <td>联系电话</td>
                </tr>
                <tr>
                    <td><input type="text" value="{$row.car_num}" readonly="readonly"></td>
                    <td><input type="text" value="{$res.car_factory_num}" readonly="readonly"></td>
                    <td><input type="text" value="{$res.car_vin}" readonly="readonly"></td>
                    <td><input type="text" value="{$res.car_engine}" readonly="readonly"></td>
                    <td><input type="text" value="{$row.sj_car_ren}" readonly="readonly"></td>
                    <td><input type="text" value="{$row.phone}" readonly="readonly"></td>
                </tr>
            </table>
            <div class="titles" style="width: 100%;height: 30px;margin: 10px 0; font-size: 14px;">
                <p><font></font>配件定损</p>
            </div>
            <table class="layui-table" id="tabProduct">
                <tr style="background:#4e73df;color: #fff;" class="ys">
                    <td></td>
                    <td>序号</td>
                    <!--<td>服务种类</td>-->
                    <td>配件名称</td>
                    <td>价格方案</td>
                    <td>价格</td>
                    <td>数量</td>
                    <td>金额</td>
                    <td>核定价格</td>
                    <td>核定数量</td>
                    <td>核价金额</td>
                    <!-- <td>操作员</td> -->
                    <td>备注</td>
                </tr>
                {volist name="peijian" id="peijians"}
                <tr>
                    <td></td>
                    <td><input type="text" readonly="readonly" value="{$peijians.xuhao}"></td>
                    <td><input type="text" readonly="readonly" value="{$peijians.name}"></td>
                    <td><input type="text" readonly="readonly" value="{$peijians.fangan}"></td>
                    <td><input type="text" readonly="readonly" value="{$peijians.price}"></td>
                    <td><input type="text" readonly="readonly" value="{$peijians.num}"></td>
                    <td><input class="price_he" type="text" readonly="readonly" value="{$peijians.money}"></td>
                    <td><input type="text" readonly="readonly" value="{$peijians.price_he}"></td>
                    <td><input type="text" readonly="readonly" value="{$peijians.num_he}"></td>
                    <td><input class="d_a_hejia" type="text" readonly="readonly" value="{$peijians.hejia}"></td>
                    <td><input type="text" readonly="readonly" value="{$peijians.beizhu}"></td>
                </tr>
                {/volist}
            </table>
            <table class="layui-table" id="he">
                <tr>
                    <td>小计</td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input id="price_he" type="text" value="{$row.benche_money}" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input id="d_a_hejia" type="text" value="{$row.benche_hejia}" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                </tr>
            </table>
        </form>
        <!--<p>汇总</p>-->
        <div class="conts">
            <div class="input">
                <span>合计</span>
                <input type="text" value="{$row.benche_heji}" readonly="readonly">
            </div>
            <div class="input">
                <span>残值</span>
                <input type="text" value="{$row.benche_canzhi}" readonly="readonly">
            </div>
            <div class="input">
                <span>总计</span>
                <input type="text" value="{$row.benche_zongji}" readonly="readonly">
            </div>
        </div>
        <div class="conts">
            <div class="input">
                <span>核定合计</span>
                <input oninput="hd_jisuan()" id="hd_a_heji" type="text" value="{$row.hd_benche_heji}" readonly>
            </div>
            <div class="input">
                <span>核定残值</span>
                <input oninput="hd_jisuan()" id="hd_a_canzhi" type="text" value="{$row.hd_benche_canzhi}" readonly>
            </div>
            <div class="input">
                <span>核定总计</span>
                <input id="hd_a_zongji" type="text" value="{$row.hd_benche_zongji}" readonly>
            </div>
        </div>
        <div class="titles">
            <p><font></font>本车工时核定</p>
        </div>
        <form action="">
            <table class="layui-table" id="tabProduct1">
                <tr style="background:#4e73df;color: #fff;" class="ys">

                    <td>序号</td>
                    <td>配件名称</td>
                    <td>价格方案</td>
                    <td>价格</td>
                    <td>数量</td>
                    <td>金额</td>
                    <td>核定价格</td>
                    <td>核定数量</td>
                    <td>核价金额</td>
                    <td>备注</td>
                </tr>
                {volist name="bengong" id="bengongs"}
                <tr>
                    <td><input type="text" readonly="readonly" value="{$bengongs.xuhao}"></td>
                    <td><input type="text" readonly="readonly" value="{$bengongs.name}"></td>
                    <td><input type="text" readonly="readonly" value="{$bengongs.fangan}"></td>
                    <td><input type="text" readonly="readonly" value="{$bengongs.price}"></td>
                    <td><input type="text" readonly="readonly" value="{$bengongs.num}"></td>
                    <td><input class="d_b_money" type="text" readonly="readonly" value="{$bengongs.money}"></td>
                    <td><input type="text" readonly="readonly" value="{$bengongs.price_he}"></td>
                    <td><input type="text" readonly="readonly" value="{$bengongs.num_he}"></td>
                    <td><input class="d_b_hejia" type="text" readonly="readonly" value="{$bengongs.hejia}"></td>
                    <td><input type="text" readonly="readonly" value="{$bengongs.beizhu}"></td>
                </tr>
                {/volist}
            </table>
            <table class="layui-table" id="he1">
                <tr>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input id="d_b_money" type="text" value="{$row.bengong_money}" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                    <td><input id="d_b_hejia" type="text" value="{$row.bengong_hejia}" readonly="readonly"></td>
                    <td><input type="text" readonly="readonly"></td>
                </tr>
            </table>
        </form>
        <!--<p>合计</p>-->
        <div class="conts">
            <div class="input">
                <span>施救费</span>
                <input type="text" value="{$row.bengong_shijiu}" readonly="readonly">
            </div>
            <div class="input">
                <span>总计</span>
                <input type="text" value="{$row.bengong_zongji}" readonly="readonly">
            </div>
        </div>
        <div class="conts">
            <div class="input">
                <span>核定施救费</span>
                <input oninput="hd_jisuan2()" id="hd_b_shijiu" type="text" value="{$row.hd_bengong_shijiu}" readonly>
            </div>
            <div class="input">
                <span>核定总计</span>
                <input id="hd_b_zongji" type="text" value="{$row.hd_bengong_zongji}" readonly>
            </div>
        </div>
        <div class="conts" style="display: none">
            <div class="input">
                <span>费用合计</span>
                <input type="text" readonly value="{$row.bc_heji}" name="bc_heji" id="bc_heji">
            </div>
        </div>

        <div class="conts">
            <div class="input dong">
                <span>诉讼费</span>
                <input type="text" id="tian_benche_susong" oninput="jisuan_money1(this)" value="{$row.benche_susong}">
            </div>
            <div class="input dong">
                <span>鉴定费</span>
                <input type="text" id="tian_benche_jianding" oninput="jisuan_money1(this)"
                       value="{$row.benche_jianding}">
            </div>
            <div class="input dong">
                <span>公估费</span>
                <input type="text" id="tian_benche_gonggu" oninput="jisuan_money1(this)" value="{$row.benche_gonggu}">
            </div>
            <div class="input dong">
                <span>住宿费</span>
                <input type="text" id="tian_benche_zhusu" oninput="jisuan_money1(this)" value="{$row.benche_zhusu}">
            </div>
            <div class="input dong">
                <span>路桥费</span>
                <input type="text" id="tian_benche_luqiao" oninput="jisuan_money1(this)" value="{$row.benche_luqiao}">
            </div>
            <div class="input dong">
                <span>燃油费</span>
                <input type="text" id="tian_benche_ranyou" oninput="jisuan_money1(this)" value="{$row.benche_ranyou}">
            </div>
            <div class="input dong">
                <span>其他</span>
                <input type="text" id="tian_benche_qita" oninput="jisuan_money1(this)" value="{$row.benche_qita}">
            </div>
            <div class="input dong">
                <span>汇总</span>
                <input type="text" id="tian_benche_huizong" value="{$row.benche_huizong}">
            </div>
            <input type="hidden" id="tian_id" value="{$row.id}">
        </div>
        <div class="conts">
            <div class="input dong">
                <span>核定诉讼费</span>
                <input type="text" readonly id="hd_tian_benche_susong" oninput="jisuan_money1(this)"
                       value="{$row.hd_benche_susong}">
            </div>
            <div class="input dong">
                <span>核定鉴定费</span>
                <input type="text" readonly id="hd_tian_benche_jianding" oninput="jisuan_money1(this)"
                       value="{$row.hd_benche_jianding}">
            </div>
            <div class="input dong">
                <span>核定公估费</span>
                <input type="text" readonly id="hd_tian_benche_gonggu" oninput="jisuan_money1(this)"
                       value="{$row.hd_benche_gonggu}">
            </div>
            <div class="input dong">
                <span>核定住宿费</span>
                <input type="text" readonly id="hd_tian_benche_zhusu" oninput="jisuan_money1(this)"
                       value="{$row.hd_benche_zhusu}">
            </div>
            <div class="input dong">
                <span>核定路桥费</span>
                <input type="text" readonly id="hd_tian_benche_luqiao" oninput="jisuan_money1(this)"
                       value="{$row.hd_benche_luqiao}">
            </div>
            <div class="input dong">
                <span>核定燃油费</span>
                <input type="text" readonly id="hd_tian_benche_ranyou" oninput="jisuan_money1(this)"
                       value="{$row.hd_benche_ranyou}">
            </div>
            <div class="input dong">
                <span>核定其他</span>
                <input type="text" readonly id="hd_tian_benche_qita" oninput="jisuan_money1(this)"
                       value="{$row.hd_benche_qita}">
            </div>
            <div class="input dong">
                <span>核定汇总</span>
                <input type="text" readonly id="hd_tian_benche_huizong" value="{$row.hd_benche_huizong}">
            </div>
        </div>
        <div class="conts">
            <span style="width:98%;margin: 1%;">备注说明</span>
            <textarea name="" cols="30" rows="10" style="width:98%;height: 100px;margin: 1%;" readonly="readonly">{$row.benche_beizhu}</textarea>
<!--            <button type="button" onclick="baocun(this)">保存</button>-->
        </div>
        <script>
            function price_he_hejia() {
                var price_he = $('.price_he');
                var d_a_hejia = $('.d_a_hejia');
                var sum = 0;
                for (var i = 0; i < price_he.length; i++) {
                    sum += Number(price_he[i].value);
                }
                $("#price_he").val(sum.toFixed(2));
                sum = 0;
                for (var i = 0; i < d_a_hejia.length; i++) {
                    sum += Number(d_a_hejia[i].value);
                }
                $("#d_a_hejia").val(sum.toFixed(2));
            }

            price_he_hejia();

            function price_hejia() {
                var d_b_money = $('.d_b_money');
                var d_b_hejia = $('.d_b_hejia');
                var sum = 0;
                for (var i = 0; i < d_b_money.length; i++) {
                    sum += Number(d_b_money[i].value);
                }
                $("#d_b_money").val(sum.toFixed(2));
                sum = 0;
                for (var i = 0; i < d_b_hejia.length; i++) {
                    sum += Number(d_b_hejia[i].value);
                }
                $("#d_b_hejia").val(sum.toFixed(2));
            }

            price_hejia();

            function jisuan_money(money) {
                money = parseFloat(money);
                if (!money || isNaN(money)) money = 0;
                return money;
            }

            function jisuan_money1(obj) {
                var parent = $(obj).closest('.conts');
                var tian_benche_susong = jisuan_money($('#tian_benche_susong', parent).val());
                var tian_benche_jianding = jisuan_money($('#tian_benche_jianding', parent).val());
                var tian_benche_gonggu = jisuan_money($('#tian_benche_gonggu', parent).val());
                var tian_benche_zhusu = jisuan_money($('#tian_benche_zhusu', parent).val());
                var tian_benche_luqiao = jisuan_money($('#tian_benche_luqiao', parent).val());
                var tian_benche_ranyou = jisuan_money($('#tian_benche_ranyou', parent).val());
                var tian_benche_qita = jisuan_money($('#tian_benche_qita', parent).val());

                var total = tian_benche_susong + tian_benche_jianding + tian_benche_gonggu + tian_benche_zhusu + tian_benche_luqiao + tian_benche_ranyou + tian_benche_qita;
                if (isNaN(total)) total = 0;
                $('#tian_benche_huizong').val(total.toFixed(2));
            }

            function baocun(sub) {
                var tian_id = $("#tian_id").val();
                var tian_benche_susong = $("#tian_benche_susong").val();
                var tian_benche_jianding = $("#tian_benche_jianding").val();
                var tian_benche_gonggu = $("#tian_benche_gonggu").val();
                var tian_benche_zhusu = $("#tian_benche_zhusu").val();
                var tian_benche_luqiao = $("#tian_benche_luqiao").val();
                var tian_benche_ranyou = $("#tian_benche_ranyou").val();
                var tian_benche_qita = $("#tian_benche_qita").val();
                var tian_benche_huizong = $("#tian_benche_huizong").val();

                $.ajax({
                    url: "{:url('bushen/lisuan/baocun_tian')}",
                    data: {
                        tian_id: tian_id,
                        tian_benche_susong: tian_benche_susong,
                        tian_benche_jianding: tian_benche_jianding,
                        tian_benche_gonggu: tian_benche_gonggu,
                        tian_benche_zhusu: tian_benche_zhusu,
                        tian_benche_luqiao: tian_benche_luqiao,
                        tian_benche_ranyou: tian_benche_ranyou,
                        tian_benche_qita: tian_benche_qita,
                        tian_benche_huizong: tian_benche_huizong
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        layer.msg(res.msg);
                    }
                })
            }
        </script>
    </div>
    <script>
        function test2() {
            var div3 = document.getElementById("div3");
            if (div3.style.display == "block") {
                div3.style.display = "none";
            } else {
                div3.style.display = "block";
            }
        }
    </script>
    {if $lisuan != ''}
    {include file="bushen/jiean/lisuan" /}
    {include file="bushen/jiean/buchangkuan" /}
    {/if}
</div>
